import sys
import os
import pymysql

if __name__ == '__main__':
    conn = pymysql.Connect(host = '10.170.128.56',
                           port = 3306,
                           user = 'root',
                           passwd = '123456',
                           db = 'cnki_humantity_simple',
                           charset='utf8mb4')
    cur = conn.cursor()
    sql="selrct * from wx_person_copy_simple"
    cur.execute(sql)
    datas=cur.fetchall()
    sql_columns="select COLUMN_NAME,DATA_TYPE from INFORMATION_SCHEMA.Columns where TABLE_SCHEMA = 'cnki_humantity_simple' and table_name='wx_person_copy_simple'"
    cur.execute(sql_columns)
    result=cur.fetchall()
    w=open("E:\\work\\human\\tmp.txt","a",encoding="gb2312")
    for data in datas:
        rec=[]
        rec.append('<REC>')
        for i in range(len(all)):
            rec.append(all[i]+str(data[i]))
        rec='\n'.join(rec)
        w.write(rec+'\n')
    w.close()